package com.wechat.service;

import com.wechat.dao.UserRechargeRecordDao;
import com.wechat.entity.UserRechargeRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 *
 * @author cgc
 * @date 18/4/9
 */
@Service
public class UserRechargeService {

    @Autowired
    private UserRechargeRecordDao userRechargeRecordDao;

    /**
     *
     */
    public int deleteById(Long id) {
        return userRechargeRecordDao.deleteById(id);
    }

    /**
     *
     */
    public int save(UserRechargeRecord record) {
        return userRechargeRecordDao.save(record);
    }

    /**
     *
     */
    @Transactional(readOnly = true,rollbackFor = Exception.class)
    public UserRechargeRecord findById(Long id) {
        return userRechargeRecordDao.findById(id);
    }

    /**
     *
     */
    public int update(UserRechargeRecord record) {
        return userRechargeRecordDao.update(record);
    }

    /**
     * 获取充值记录列表
     * @param userId
     * @param tradeStatus
     * @param dateTradedBegin
     * @param dateTradedEnd
     * @return
     */
    @Transactional(readOnly = true,rollbackFor = Exception.class)
    public List<UserRechargeRecord> list(Integer userId,
                                  Integer tradeStatus,
                                  Date dateTradedBegin,
                                  Date dateTradedEnd,
                                  Date createTimeBegin,
                                  Date createTimeEnd){
        return userRechargeRecordDao.list(userId,tradeStatus,dateTradedBegin,dateTradedEnd,createTimeBegin,createTimeEnd);
    }


}
